{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Here we test and check the performance of the `Hk` implementation."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "from pathlib import Path\n",
    "import numpy as np\n",
    "import sisl as si\n",
    "\n",
    "files = Path(os.environ[\"SISL_FILES_TESTS\"])\n",
    "siesta = files / \"siesta\"\n",
    "\n",
    "N = 10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "H = si.Hamiltonian.read(siesta / \"Si_pdos_k\" / \"Si_pdos.TSHS\").tile(N, 0).tile(N, 1)\n",
    "\n",
    "print(H.dtype)\n",
    "%timeit H.Hk()\n",
    "%timeit H.Hk([0.1] * 3)\n",
    "%timeit H.Hk(format=\"array\")\n",
    "%timeit H.Hk([0.1] * 3, format=\"array\")\n",
    "\n",
    "H = H.astype(np.complex128)\n",
    "print(H.dtype)\n",
    "%timeit H.Hk()\n",
    "%timeit H.Hk([0.1] * 3)\n",
    "%timeit H.Hk(format=\"array\")\n",
    "%timeit H.Hk([0.1] * 3, format=\"array\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "H = si.Hamiltonian.read(siesta / \"Pt2_soc\" / \"Pt2_xx.TSHS\").tile(N, 0).tile(N // 2, 1)\n",
    "\n",
    "print(H.dtype)\n",
    "%timeit H.Hk()\n",
    "%timeit H.Hk([0.1] * 3)\n",
    "%timeit H.Hk(format=\"array\")\n",
    "%timeit H.Hk([0.1] * 3, format=\"array\")\n",
    "\n",
    "H = H.astype(np.complex128)\n",
    "print(H.dtype)\n",
    "%timeit H.Hk()\n",
    "%timeit H.Hk([0.1] * 3)\n",
    "%timeit H.Hk(format=\"array\")\n",
    "%timeit H.Hk([0.1] * 3, format=\"array\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
